package com.gxa.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.gxa.common.JsonResult;
import com.gxa.service.EmpService;
import com.gxa.service.impl.EmpServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/employee/search")
public class SearchEmpServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Integer currentpage = Integer.parseInt(req.getParameter("page"));
        Integer pagesize = Integer.parseInt(req.getParameter("limit"));
        String username = req.getParameter("username");
        EmpService empService = new EmpServiceImpl();
        JsonResult jsonResult = empService.queryEmpList(currentpage, pagesize, username);
        resp.setContentType("application/json;charset=utf-8");
        resp.getWriter().write(JSONObject.toJSONString(jsonResult));
    }
}
